Skip to main content link. Accesskey S
  • Help
  • HCL Logo
  • HCL Notes and Domino Application Development wiki
  • THIS WIKI IS READ-ONLY. Individual names altered for privacy purposes.
  • HCL Forums and Blogs
  • Home
  • Product Documentation
  • Community Articles
  • Learning Center
  • API Documentation
Search
Community Articles > Developing Applications > Developing Form- and View-based Applications > split checkbox field into multiple fields without re-saving all existing docs
  • Share Show Menu▼
  • Subscribe Show Menu▼

Recent articles by this author

Onblur - runs more than once - is there a fix?

summary I'll use an example to explain.  I have a document that users record to track number of items completed (numItems) and total time (time).  numItems should be an integer and time should be hh:mm.  I have 20 of these on the document and I have totals and other things, but that's beyond the ...

view with multiple rows for a single document

summary  This seems so elementary, but I don't use these very often and it seems like every time I get a little stuck, so I decided it's worth documenting.  This is how to display multiple rows of data from a single Notes document.  I often use this concept when I have a business area that needs a ...

split checkbox field into multiple fields without re-saving all existing docs

Existing field is a multivalue check box.  Let's call this field  cities    Need to split into multiple fields without resaving every document in the database.  Let's call these fields  citiesMN and citiesWI   Step 1:  Hide cities field Step 2:  New fields citiesMN citiesWI are ...
Community articlesplit checkbox field into multiple fields without re-saving all existing docs
Added by ~Mark Minretherikle | Edited by ~Mark Minretherikle on October 26, 2011 | Version 8
  • Actions Show Menu▼
expanded Abstract
collapsed Abstract
No abstract provided.
  • Existing field is a multi-value check box.  Let's call this field cities  
  • Need to split into multiple fields without re-saving every document in the database.  Let's call these fields cities_MN and cities_WI 
  • Step 1:  Hide cities field
  • Step 2:  New fields cities_MN & cities_WI are editable checkbox fields with default value of cities
    • This is the concept.  Even before a document is re-saved this change will allow the appropriate value(s) from cities field to display in cities_MN & cities_WI fields
    • How do they separate?  Based on the field choices of the new fields cities_MN & cities_WI
  • Pitfalls.  Prior to re-saving, data in existing docs is saved in cities field but cities_MN & cities_WI fields are still null "".  Need to be careful with any view selection criteria, agents, or any other processing we do
  • Example:
    • cities field has field choices of "Appleton, WI"; "Madison, WI"; "Woodbury, MN"; "Saint Paul, MN"; "New York, NY" and let's just say all 5 are checked, so cities field has all 5 values stored
    • Pre-save & after the split
      • cities_MN field has field choices "Woodbury, MN"; "Saint Paul, MN"; "Minneapolis, MN"
      • cities_MN field has value stored as "", but when displayed will display "Woodbury, MN" & "Saint Paul, MN" (because the default value on this field is "cities" and Notes can display this even before it's saved and updated)
      • "Minneapolis, MN" will not be displayed since it wasn't checked in the cities field
    • Post-save
      • cities_MN field will have value stored as "Woodbury, MN"; "Saint Paul, MN"
    • dido for cities_WI field

Views and how to handle:

  • cities will always be in available in views, but won't be correct once a doc is saved and cities_MN & cities_WI are created, then we MUST use the new cities_MN & cities_WI fields to ensure data accuracy
  • again, our cities field has field choices of "Appleton, WI"; "Madison, WI"; "Woodbury, MN"; "Saint Paul, MN"; "New York, NY", and assuming we don't want do display cities outside WI/MN, our view selection formula could look something like this:
    • include := "";
    • @If(@IsAvailable(cities_MN);
    • values := cities_MN:cities_WI;
    • values := cities;
    • @If(@Contains(values; "Appleton, WI"); (include := "yes"); "");
      @If(@Contains(values; "Madison, WI"); (include := "yes"); "");
      @If(@Contains(values; "Saint Paul, MN"); (include := "yes"); "");
      @If(@Contains(values; "Woodbury, MN"); (include := "yes"); "");
    • SELECT
      (include = "yes")
  • our view formula could look something like this:
    • display := "" 
    • @If(@IsAvailable(cities_MN);
    • display := cities_MN:cities_WI;
    • display := cities;
    • display
    • http://postimage.org/image/ejfge4wy3/
  • @IsAvailable checks to see if the field exists, and we could have picked either cities_MN or cities_WI since they're both created at the exact same time
  • this view is going to display all the cities that are checked on the form
    • when the new fields aren't there we go ahead and display the old cities field
    • when the new fields exist (though they could still be null "") we display cities_MN and cities_WI
  • pitfall: cities is hidden and contains "bad data" once the new fields are created, and this is a drawback of splitting the field and is something we need to handle in views and other situations where we handle data 

Conclusion:

  • It would have been better to find a way not to split the field like this in the first place, but it was already done before I got involved.  Next time, I'd probably start the same way.  Hide the old field and split into 2 new fields defaulted to the old field.  Then I'd write an agent to re-compute & re-save all docs to force the new fields to pickup and save their defaults.  Then I'd get rid of the original field.  What seems like a good idea sometimes turns into a mess.

  • Actions Show Menu▼


expanded Attachments (0)
collapsed Attachments (0)
Edit the article to add or modify attachments.
expanded Versions (8)
collapsed Versions (8)
Version Comparison     
VersionDateChanged by              Summary of changes
This version (8)Oct 26, 2011, 9:27:08 PM~Mark Minretherikle  added a "this wasn't really a good idea" conclusion
7Oct 25, 2011, 10:03:47 PM~Wei Destooverynds  added link to code sample
6Oct 25, 2011, 9:58:20 PM~Wei Destooverynds  added comments on using in views
5Oct 25, 2011, 2:22:41 PM~Wei Destooverynds  removed color since it's not displayed in the wiki
4Oct 25, 2011, 2:21:02 PM~Wei Destooverynds  added bold for clarity
3Oct 25, 2011, 2:07:50 PM~Wei Destooverynds  converted to bulleted format
2Oct 25, 2011, 3:45:24 AM~Wei Destooverynds  added bold to "change the default value of each to "cities"'
1Oct 25, 2011, 3:43:32 AM~Wei Destooverynds  
expanded Comments (0)
collapsed Comments (0)
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedAbout
  • HCL Software
  • HCL Digital Solutions community
  • HCL Software support
  • BlogsDigital Solutions blog
  • Community LinkHCL Software forums and blogs
  • About HCL
  • Privacy
  • Accessibility